package com.chiyi.controller;

import com.chiyi.bean.TProduct;
import com.chiyi.service.WebService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Random;

/**
 * @date 2021/5/13 17:40
 */
@RestController
@Api(tags = "web")
public class WebController {

    @Resource
    private WebService webService;

    @ApiOperation("work")
    @GetMapping("/work")
    public String work() {
        int i = new Random().nextInt(10);
        if (i % 3 != 0) {
            throw new RuntimeException();
        }
        return "success";
    }

    @ApiOperation("获取全部商品")
    @GetMapping("/getAllProduct")
    public List<TProduct> getAllProduct() {
        return webService.getAllProduct();
    }


}
